package io.vanaheimr.account;

import io.micronaut.core.annotation.Introspected;
import io.vanaheimr.common.core.Status;
import io.vanaheimr.common.db.BaseEntity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

@Getter
@Setter
@ToString(callSuper = true)
@Introspected
@Entity
public class Group extends BaseEntity {

    private String name;

    private String remark;

    private Status status;


    private String path;

    @ManyToOne
    @JoinColumn(name = "parent_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Group superGroup;

    @OneToMany(mappedBy = "superGroup")
    @JoinColumn(name = "parent_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    @ToString.Exclude
    private List<Group> children;

    @OneToOne
    @JoinColumn(name = "manager_account_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Account manager;
}
